﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace work
{
    public partial class EditGarde : Form
    {
        public string getKey1;
        public string getKey2;
        public string getKey3;
        public string getKey4;

        public void setKey1(String key)
        {
            getKey1 = key;
        }
        public void setKey2(String key)
        {
            getKey2 = key;
        }
        public void setKey3(String key)
        {
            getKey3 = key;
        }
        public void setKey4(String key)
        {
            getKey4 = key;
        }
        public EditGarde()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "server=.;database=Schools;user id=sa;password=123";
            conn.Open();
            SqlCommand cmd = new SqlCommand();


            cmd.CommandText = "update Students set Score= '" + textBox3.Text.Trim() + "' where Name= '" + textBox1.Text.Trim()+"' ";
            cmd.Connection = conn;

            cmd.ExecuteNonQuery();
            conn.Close();

            this.textBox1.Text = "";
            this.textBox2.Text = "";
            this.textBox3.Text = "";



            MessageBox.Show("修改成功");
            this.Hide();
            try
            {
                Form f = this.Owner;
                ((AllGrade)f).refresh();
            }
            catch
            {

            }
        }

        private void EditGarde_Load(object sender, EventArgs e)
        {
            this.textBox1.Text = getKey2;
            this.textBox2.Text = getKey3;
            this.textBox3.Text = getKey4;
        }
    }
}
